class WookieWikiController < ApplicationController

  def upload
    @tiddler = Upload.new( params[:tiddler])
    if @tiddler.title == "New File Upload" 
      responds_to_parent do
        render :update do |page|
          page << "alert('Please enter a title.');" 
        end
      end
      return
    end
    @tiddler.save!
    #redirect_to :controller => 'wiki', :action => 'view'
    string = <<-END 
    newTitle = "#{@tiddler.title}";
    newBody = "#{@tiddler.body.gsub(/\n/, '\n')}";
    newTags = "#{@tiddler.tags.gsub(/\n/, '\n')}";
    store.saveTiddler("New File Upload", newTitle, newBody, config.options.txtUserName, new Date(), newTags);
    END
    logger.debug string
    responds_to_parent do
      render :update do |page|
        #page << "deleteTiddler('New File Upload');"
        page <<  string 
        page << "displayTiddler(null,newTitle,1,null,null,null,false,false);"
        page << "deleteTiddler('New File Upload'); "
      end
    end
  end

  def serialize
    render :inline => "success"
  end
end
